package com.cloud.eurekaprovider1.controller;

import com.cloud.eurekaprovider1.config.ServerConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author kangwen
 */
@Slf4j
@RestController
public class EurekaProviderController {

	@Resource
	private ServerConfig serverConfig;

	@RequestMapping("/hi")
	public String hi() {
		return "hi 这里是 eureka 服务提供方1, on port=" + serverConfig.getPort();
	}

	@RequestMapping("/hello")
	public String hello() {
		return "hello 这里是 eureka 服务提供方, on port=" + serverConfig.getPort();
	}


	@GetMapping("/timeout/{ms}")
	public String timout(@PathVariable Long ms) {
		log.info("timeout in, on port={}", serverConfig.getPort());
		try {
			if (ms != null) {
				Thread.sleep(ms);
			}
		} catch (InterruptedException e) {
		}
		return "timeout 这里是 eureka 服务提供方, on port=" + serverConfig.getPort();
	}
}
